##Data Wrangling

fish_all <- fish_all %>%
  mutate(species_group = case_when(
    FISH %in% c("Blue Crabs, Hard", "Shrimp (Heads On)") 
      ~ "Crustaceans",
    FISH %in% c("Clams, Hard (Meats)", "Oysters (Meats)") 
      ~ "Bivalves (Shellfish)",
    FISH %in% c("Flounder, Southern", "Flounder, Summer") 
      ~ "Flatfish (Flounders)",
    FISH %in% c("Mackerel, King", "Mackerel, Spanish") 
      ~ "Mackerels",
    FISH %in% c("Perch, White", "Perch, Yellow") 
      ~ "Perches",
    FISH %in% c("Mullet, Sea (Kingfishes)", "Mullet, Striped") 
      ~ "Mullets",
    FISH %in% c("Croaker, Atlantic", "Drum, Black", "Drum, Red", 
                "Seatrout, Spotted", "Weakfish (Grey Trout)") 
      ~ "Drums & Croakers",
    FISH %in% c("Shad, American", "Shad, Hickory") 
      ~ "Shads",
    FISH %in% c("Bluefish", "Butterfish", "Carp", "Catfishes", "Cobia", 
                "Eel, American", "Grunts", "Harvestfish (Starbutters)", 
                "Pigfish", "Pompano", "Porgies", "Pufferfish", "Sea Basses",
                "Sheepshead", "Snappers, Other", "Spadefish", "Spot", "Squid",
                "Striped Bass") 
      ~ "Other Common Finfish",
    FISH %in% c("Unclassified Fish For Industrial/Bait", 
                "Unclassified Fish for Food", "Unclassified Shellfish") 
      ~ "Unclassified Categories",
    TRUE ~ "Other"))

##Exploratory Plots

##Statistical Analysis

##              Df    Sum Sq   Mean Sq F value   Pr(>F)    
## FINALWEIGHT   1 7.807e+14 7.807e+14   65.44 5.12e-15 ***
## Residuals   471 5.618e+15 1.193e+13                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Call:
## lm(formula = FINALVALUE ~ FINALWEIGHT, data = fish_all)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -12043390  -1038478   -958461   -474322  27343344 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.048e+06  1.628e+05   6.438 2.98e-10 ***
## FINALWEIGHT 8.966e-02  1.108e-02   8.090 5.12e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3454000 on 471 degrees of freedom
## Multiple R-squared:  0.122,  Adjusted R-squared:  0.1201 
## F-statistic: 65.44 on 1 and 471 DF,  p-value: 5.116e-15
## 
## Call:
## lm(formula = FINALVALUE ~ FINALWEIGHT + species_group, data = fish_all)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -12868469   -183198   -100557    115049  17009372 
## 
## Coefficients:
##                                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                           2.724e+06  4.280e+05   6.365 4.72e-10 ***
## FINALWEIGHT                           4.753e-02  7.280e-03   6.530 1.74e-10 ***
## species_groupCrustaceans              1.085e+07  6.173e+05  17.575  < 2e-16 ***
## species_groupDrums & Croakers        -2.221e+06  5.242e+05  -4.238 2.73e-05 ***
## species_groupFlatfish (Flounders)     1.130e+06  6.055e+05   1.866 0.062651 .  
## species_groupMackerels               -1.854e+06  6.053e+05  -3.063 0.002318 ** 
## species_groupMullets                 -2.017e+06  6.053e+05  -3.332 0.000932 ***
## species_groupOther                   -2.246e+06  5.780e+05  -3.887 0.000117 ***
## species_groupOther Common Finfish    -2.541e+06  4.499e+05  -5.647 2.86e-08 ***
## species_groupPerches                 -2.622e+06  6.053e+05  -4.331 1.82e-05 ***
## species_groupShads                   -2.647e+06  6.053e+05  -4.373 1.52e-05 ***
## species_groupUnclassified Categories -2.661e+06  5.527e+05  -4.814 2.01e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2007000 on 461 degrees of freedom
## Multiple R-squared:  0.7097, Adjusted R-squared:  0.7028 
## F-statistic: 102.5 on 11 and 461 DF,  p-value: < 2.2e-16